﻿using System.Web.UI.WebControls;

namespace N2.Workflow.Items
{
	using Definitions;
	using Details;
	using N2.Edit.Trash;
	using Persistence;
	using Web.UI.WebControls;

	[Disable, Definition, NotThrowable, NotVersionable]
	[ItemAuthorizedRoles("Administrators")]
	public partial class ItemState: ContentItem
	{
		[EditableTextBox("Comment", 13, Rows=3, TextMode = TextBoxMode.MultiLine)]
		public string Comment {
			get { return this.GetDetail("Comment") as string; }
			set { this.SetDetail<string>("Comment", value); }
		}
		
		public StateDefinition Definition {
			get { return this.GetDetail("ToState") as StateDefinition; }
			set { this.SetDetail<StateDefinition>("ToState", value); }
		}

		public ActionDefinition Action {
			get { return this.GetDetail("Action") as ActionDefinition; }
			set { this.SetDetail<ActionDefinition>("Action", value); }
		}

		public ItemState PreviousState {
			get { return this.GetDetail<ItemState>("PreviousState", null); }
			set { this.SetDetail<ItemState>("PreviousState", value); }
		}

		[Editable("Assigned To", typeof(SelectUser), "SelectedUser", 240)]
		public string AssignedTo {
			get { return this.GetDetail<string>("AssignedTo", string.Empty); }
			set { this.SetDetail<string>("AssignedTo", value); }
		}

		public override bool IsPage { get { return false; } }

		public override string IconUrl {
			get {
				return null != this.Definition
					? this.Definition.Icon
					: Constants.IconPath + "46.png"; }
		}

		public override string TemplateUrl { get { return "~/Templates/Secured/Go.aspx"; } }

		public override bool Visible { get { return false; } }
	}
}
